home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / cbm / 4237 < prev    next >
Encoding:
Text File  |  1996-08-05  |  5.3 KB  |  101 lines

  1. Path: news.tu-chemnitz.de!fachat
  2. From: fachat@physik.tu-chemnitz.de (Andre Fachat)
  3. Newsgroups: comp.sys.cbm,comp.os.misc,alt.comp.hardware.homebuilt,comp.sys.apple2,comp.sys.apple2.programmer,comp.sys.atari.8bit
  4. Subject: Re: 6502 Multitasking OS announce
  5. Followup-To: comp.sys.cbm,comp.os.misc,alt.comp.hardware.homebuilt,comp.sys.apple2,comp.sys.apple2.programmer,comp.sys.atari.8bit
  6. Date: 19 Mar 1996 15:48:49 GMT
  7. Organization: University of Technology Chemnitz, FRG
  8. Message-ID: <4iml11$s69@narses.hrz.tu-chemnitz.de>
  9. References: <4i94fs$stj@narses.hrz.tu-chemnitz.de> <holger.948.00030EE6@deep.hb.provi.de> <4ijtbe$7ca@no-names.nerdc.ufl.edu> <4ijuic$iiq@gatekeeper.liffe.com> <4ik00v$9r@fishlab7.fsh.mtu.edu> <4im8k0$gud@gatekeeper.liffe.com>
  10. NNTP-Posting-Host: dag.physik.tu-chemnitz.de
  11. X-Newsreader: TIN [version 1.2 PL2]
  12.  
  13. Ralph Mason (ralph.mason@liffe.com) wrote:
  14. : There is much more needed that to simply save the registers! He
  15. : doesn't explain what he is doing, the only way I can see that he is
  16. : doing it is using his mmu to swap the bottom 4kb during each context
  17. : switch.  This would give each process it's own stack and zeropage
  18. : space.  You can then pass parameters on the stack or in the zeropage -
  19. : it's up to you.  I would lean toward the stack though because you
  20. : could not have rentrant routines or share code between processes.  
  21.  
  22. Well, I should have gone further into this.
  23. The thing is that I have two versions of the OS, one for a computer with MMU,
  24. and another one for a 6502 without. 
  25.  
  26. With an MMU, each task gets its real own memory space, i.e. 
  27. zeropage and stack are remapped with the bottom 4kByte at each context 
  28. switch. This way every task sees its own stack and has its own
  29. view of the memory - it doesn't see anything of other tasks, or the 
  30. system. The kernel entry/exit gates provide a way to change from
  31. system memory mapping (which is just the botton 4kByte RAM with the 
  32. system stuff and the top 4kByte ROM with the kernel) and the 
  33. task environment. This is a complete mapping of the bottom 60kByte
  34. (well, with I/O, the bottom 58kByte) of CPU address space. The task 
  35. environment can be mapped to RAM, ROM, special addresses that have 
  36. different features (like video RAM) and the like.
  37. Normal tasks will have 4 or 8 kByte RAM, the system ROM for the
  38. stdlib at $e***, the kernel at $f*** and the rest filled with nothing...
  39. (mirroring the kernel)
  40.  
  41. Without an MMU, there is the problem with the non-relocatable stack the
  42. 6502 has. So, to avoid swapping stack contents around, I divided the 
  43. stack into 7 parts, i.e. 6 possible tasks with 32 Byte stack each and
  44. the system with 64 byte. Because there is no boundary testing, this
  45. is a 'dirty trick' (tm) to get it running even without MMU.
  46. But even then only programs that cooperate, i.e. use different memory
  47. locations can run at the same time - otherwise bad things happen, when
  48. one tasks writes over important data for another one.
  49.  
  50. Most kernel routines are called with the parameters in the CPU registers.
  51. And most kernel routines do not need morei (see the kernel interface
  52. description). But a few of them need, 
  53. and for them there is a special area - not the zeropage but $02** - 
  54. reserved to which the parameter are written. 
  55.   
  56. To share code between processes, you need not put the parameter on the
  57. stack. The shell, e.g. is in the ROM. The same program can run several 
  58. times in different tasks without any problem. This works because
  59. the used RAM is mapped to different pages for different tasks. 
  60. You can also load an executable into some RAM and let two tasks share this
  61. RAM. As long as they don't write to it, there's no problem. For writing
  62. they use the task specific RAM.
  63.  
  64. reentrant routines - well, the kernel is in some respect reentrant.
  65. internal kernel routines call other kernel routines via the same 
  66. interface as other 'user' routines as well. The kernel entry/exit gates 
  67. detect this and do not change the memory mapping. 
  68. Devices, that have their own memory mapping and that are called via
  69. the DEVCMD interface call kernel routines. 
  70. But then only some routines are a kind of reentrant, esp. the STREAM routines.
  71. They disable Multitasking during their critical sections. The problem
  72. with the C64 is, that is doesn't have atomic test&set operations. So all
  73. task switches have to be disabled to test a semaphore, or when you enter
  74. a critical region.
  75. The memory routines, for example, cannot be called from an
  76. interrupt. They are not protected against reentrance and therefore 
  77. a call from an interrupt can corrupt the stuff. Though the video device
  78. for example calls ENMEM to enable the RAM on the video board at startup.
  79. But this startup is not called from an interrupt.
  80.  
  81. The kernel as well as the video  device are interruptable. But then, if a task
  82. is calling a kernel function during the interrupt, the task is not 
  83. set waiting but is kept running after the interrupt. This is needed
  84. to avoid an interrupted system call - and then another task calling
  85. the same routine - to corrupt internal data.
  86. The video device interrupt routine is interruptible, but it has its own 
  87. reentrance check to avoid confusion
  88.  
  89. hope it helps and so long
  90. Andre
  91.  
  92.  
  93.  
  94.  
  95.  
  96. --
  97. fachat@physik.tu-chemnitz.de | Andre Fachat,        Phone: ++49-371-531-3551
  98. -----------------------------| Vettersstr. 72/622,  09126 Chemnitz,  Germany
  99. Distribution via the         |---------------------------------------------- 
  100. Microsoft Network prohibited!| Unix was invented prior to user-friendlyness!
  101.